package com.cq.hd.system.controller;


import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.system.service.TbContentService;
import com.cq.hd.system.api.TbContentApi;
import com.cq.hd.system.api.dto.ContentPageDto;
import com.cq.hd.system.api.dto.ContentSaveDto;
import com.cq.hd.system.api.dto.ContentUpdateDto;
import com.cq.hd.system.api.dto.ContentUpdateStateDto;
import com.cq.hd.system.api.vo.ContentPageVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学堂详情表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-19
 */
@RestController
public class TbContentController implements TbContentApi {

    @Autowired
    private TbContentService contentService;

    @ApiOperation(value = "学院文章列表")
    @ApiImplicitParam(name = "contentPageDto", value = "学院文章查询参数", required = true, paramType = "query", dataType = "ContentPageDto")
    @ApiResponse(response = ContentPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<ContentPageVo>> pageContent(ContentPageDto contentPageDto) {
        return ResultGenerator.success(contentService.pageContent(contentPageDto));
    }

    @ApiOperation(value = "保存学院文章")
    @ApiImplicitParam(name = "contentSaveDto", value = "学院文章保存参数", required = true, paramType = "body", dataType = "ContentSaveDto")
    @Override
    public Result<Long> saveContent(@RequestBody ContentSaveDto contentSaveDto) {
        return ResultGenerator.success(contentService.saveContent(contentSaveDto));
    }

    @ApiOperation(value = "更新学院文章")
    @ApiImplicitParam(name = "contentUpdateDto", value = "学院文章更新参数", required = true, paramType = "body", dataType = "ContentUpdateDto")
    @Override
    public Result<Boolean> updateContent(@RequestBody ContentUpdateDto contentUpdateDto) {
        return ResultGenerator.success(contentService.updateContent(contentUpdateDto));
    }

    @ApiOperation(value = "删除学院文章")
    @ApiImplicitParam(name = "id", value = "学院文章删除参数", required = true, paramType = "query", dataType = "Long")
    @Override
    public Result<Boolean> deleteContent(Long id) {
        return ResultGenerator.success(contentService.deleteContent(id));
    }

    @ApiOperation(value = "上下架学院文章")
    @ApiImplicitParam(name = "contentUpdateStateDto", value = "学院文章上下架参数", required = true, paramType = "body", dataType = "ContentUpdateStateDto")
    @Override
    public Result<Boolean> updateState(@RequestBody ContentUpdateStateDto contentUpdateStateDto) {
        return ResultGenerator.success(contentService.updateState(contentUpdateStateDto));
    }

}
